package com.msb.nacos.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/****************************************************
 *
 * @author lbf
 * @date 2025/6/16 11:28
 ****************************************************/
@RestController
public class ConsumerController {

    @Value("${nacos-service.service-url}")
    private String targetService;

    @Autowired
    private RestTemplate restTemplate;

    @GetMapping("/test")
    public String test(){

        //使用 RestTemplate 开启远程调用
        ResponseEntity<String> result = restTemplate.getForEntity(targetService+"/test",String.class);

        String res = result.getBody();
        return res;
    }
}
